{extend name="public:_base" /}
{block name="css"}
{CSS href="__STATIC__/w/admin_base.css" /}
{CSS href="__STATIC__/w/layui.css" /}
{CSS href="__STATIC__/w/divtable.css" /}
{/block}

{block name="js"}
{js href='__STATIC__/w/layui.js' /}
{/block}

{block name="main"}

<div class="layui-form-cont">

    <div class="layui-tab" lay-filter="docDemoTabBrief">

        <div class="layui-tab-nav">
            <div class="layui-tab-left">
                <a class="layui-btn radius layui-btn-normal" href="{:url(\''.\\think\\Request::instance()->controller().'/Add')}">
                    <i class="Hui-iconfont">&#xe600;</i> 添加活动
                </a>
            </div>

        </div>

        <div class="layui-tab-content layui-new-table">
            <table class="layui-table" lay-skin="line">
                <thead>
                <tr>
                    <th>活动</th>
                    <th>关键词</th>
                    <th>参与人数</th>
                    <th>开始时间/结束时间</th>
                    <th>外链代码</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="data" id="vo"}
                <tr>

                    <td>{$vo.title}</td>
                    <td>{$vo.keyword}</td>
                    <td>{$vo.joinnum}</td>
                    <td>{$vo.statdate|date="Y-m-d",###}<br>{$vo.enddate|date="Y-m-d",###}</td>
                    <td><a target="_blank" href="{:url('api/'.\\think\\Request::instance()->controller().'/index',['wecha_id'=>rand(1,5000),'id'=>$vo.id])}">模拟dome</a>{$vo.id}</td>
                    <td>{empty name="$vo.status" value="1"}已经开始{else/}未开始{/empty}</td>
                    <td>
                        <a class="rha-bt-a" href="javascript:;" onclick="delnewcode('{$vo.id}')">删除</a>
                        <a href="{:url(\''.\\think\\Request::instance()->controller().'/edit',['id'=>$vo.id])}" class="rha-bt-a">编辑</a>
                        <a href="{:url(\''.\\think\\Request::instance()->controller().'/checkcode',['id'=>$vo.id])}" class="rha-bt-a">中奖情况</a>
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
            {$data->render()}
        </div>
    </div>
</div>
    <script>
        function delnewcode(id) {
            layui.use('layer', function(){
                var layer = layui.layer;
                layer.confirm('你确定需要删除吗，删除不能恢复？', {
                    btn: ['是','不'] //按钮
                }, function(){
                    $.post("{:url('delGuajiang')}",{'id':id},function (res) {
                        if(res.status==1){
                            layer.alert(res.msg,function (index) {
                                window.location.reload();
                                layer.close(index);
                            })

                        }else{
                            layer.alert(res.msg)
                        }
                    })
                }, function(){

                });
            });

        }
    </script>
{/block}